#version 330 core

in vec3 v_w;
in vec3 n_w;

out vec3 fragColor;

uniform vec3 color;
uniform vec3 ambientLight;
uniform vec3 directionalLight;
uniform vec3 directionalDir_w;
uniform vec3 cameraPosition_w;

void main(){
    vec3 wi = -directionalDir_w;
    vec3 wo = normalize(cameraPosition_w-v_w);
    vec3 h = normalize(wi+wo);
    float factor = dot(h, n_w);

    fragColor = color * (ambientLight + directionalLight*(factor*factor));
}